﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using SubSonic;
using CXDB;
using Coolite.Ext.Web;
using Comparison=SubSonic.Comparison;

public partial class Search_Company_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }
    protected void Search(object s, AjaxEventArgs e)
    {
        Query q = new Query(VwCompanybase.Schema);
        if(tfcompanyid.Text!="")
        {
            q.AddWhere("companyid", Comparison.Like, "%" + tfcompanyid.Text.Trim() + "%");
        }
        if(tfcompanyname.Text!="")
        {
            q.AddWhere("companyname", Comparison.Like, "%" + tfcompanyname.Text.Trim() + "%");
        }
        q.SetSelectList("companyid,companyname,companyaddress,electricname,tradename,deptname");
        StoreCompany.DataSource = q.ExecuteDataSet();
        StoreCompany.DataBind();
    }
    protected void StoreDetail_onRefresh(object sender, StoreRefreshDataEventArgs e)
    {
        string id = e.Parameters["companyid"];
        
        Query q = new Query(CxCompanyPingJium.Schema);
        q.SetSelectList("id,companyid,companyname,dept_master_status,manager_status,intime,guid");
        q.AddWhere("companyid", id);
        q.AddWhere("dept_master_status", 1);
        q.AddWhere("manager_status", 1);
        
        StoreDetail.DataSource = q.ExecuteDataSet();
        StoreDetail.DataBind();
    }

    protected void ApplySub(object s, AjaxEventArgs e)
    {
        string id = e.ExtraParams["id"].ToString();
        tfhiddenid.Value = id;

        Window1.Show();
    }
    protected void Sub(object s, AjaxEventArgs e)
    {
        ApplyAction.Add(new Guid(tfhiddenid.Value.ToString()), tfreason.Text, "cx_company_pingjia");
        Window1.Hide();
    }
    protected void Cancel(object s, AjaxEventArgs e)
    {
        Window1.Hide();
    }
}
